# Copyright (c) 2018 Presto Labs Pte. Ltd.
# Author: xguo

from coin.exchange.base.kr_rest.feed_base import FeedBase
from coin.exchange.okex_futures.kr_rest.futures_product import (OkexFuturesProduct)
from coin.exchange.okex_futures.kr_rest.public_client import (OkexFuturesPublicClient)


class OkexFuturesV1Feed(FeedBase):
  ProductType = OkexFuturesProduct
  is_price_float = True

  def __init__(self, product):
    FeedBase.__init__(self, product)
    self.pub_client = OkexFuturesPublicClient()

  def query_book(self):
    obj = self.pub_client.query_level_book(self.product)
    self.set_book_data(obj.req_timestamp, obj.res_timestamp, obj.msg)
